clear all
capture set more off

*******************************************************************************************************************************************
// Admin
*******************************************************************************************************************************************
/*
	// Set directory path
	foreach i in "C:/Users/Andy/Dropbox/projects/WWI German Discrimination"		///
				 "C:/Users/anf137/Dropbox/projects/WWI German Discrimination"	///
				 "Z:/Dropbox/projects/WWI German Discrimination"				{
		
				global path "`i'"
				confirmdir "$path"
				if `r(confirmdir)'==0 continue, break
	}
*/
*******************************************************************************************************************************************


* prep the 1910 county level statistics for merge later
	use "$path/Replication/raw_data/1910census_county.dta"

	keep if level==1

	tempfile c1910
	save "`c1910'"
	clear

* clean the digitized enlistment data

	* load raw data
	import excel "$path/Replication/raw_data/WWI inductions by county.xlsx", sheet("Sheet1") firstrow

	* remove special characters and excess spaces
	ds, has(type string)
	foreach v in `r(varlist)' {
		replace `v' = strtrim(`v')
		replace `v' = stritrim(`v')
	}

	* format numbers
	replace tot_cancelled = subinstr(tot_cancelled, "I", "1", .)

	gen tot_called_num    = real(regexs(1)) if regexm(tot_called   ,"([0-9]+)")
	gen tot_inducted_num  = real(regexs(1)) if regexm(tot_inducted ,"([0-9]+)")
	gen tot_accepted_num  = real(regexs(1)) if regexm(tot_accepted ,"([0-9]+)")
	gen tot_rejected_num  = real(regexs(1)) if regexm(tot_rejected ,"([0-9]+)")
	gen tot_cancelled_num = real(regexs(1)) if regexm(tot_cancelled,"([0-9]+)")
	compress

	mvencode *_num, mv(0) override

	* check for errors
	gen check_inducted = tot_accepted_num + tot_rejected_num + tot_cancelled_num

	gen error = check_inducted - tot_inducted_num

	* drop state sums
	drop if board=="Total" | board=="Totel"

	* clean board/county variable, make upper case, remove special characters
	gen name = board
	split name, p("No ")
	replace name = name1
	drop name1 name2

	replace name = upper(name)

	foreach i in 40 41 45 48 49 50 51 52 53 54 55 56 57 58 59 128 153 226 {
		replace name = subinstr(name, "`=char(`i')'", "", .)
	}

	replace name = strtrim(name)

	* merge with state identifiers
	merge m:1 statefips using "$path/Replication/raw_data/statefips.dta"
	drop if _merge==2
	drop _merge

	* drop Alaska and Hawaii
	drop if statename=="Alaska" | statename=="Hawaii"

	* remove numbering of boards
	split board if board!="Del Norte", p(" No")
	replace board = board1 if board!=board1

	drop board1 board2

	ren stateicp state

	* merge with 1910 census on name and state (this merges most of the county codes)
	merge m:1 name state using "`c1910'", keepusing(county)
	drop if _merge==2

	
* now take care for places with typos or which are cities (instead of counties, hence they don't match w 1910 census)

* DC
replace county =  10 if statefips==11

* Alabama
replace county =  730 if board=="Birmingham"		& statefips==1
replace county =  150 if board=="Calhoun"			& statefips==1
replace county =  210 if board=="Chilton"			& statefips==1
replace county =  490 if board=="Dekalb"			& statefips==1
replace county =  750 if board=="Lamar"				& statefips==1
replace county = 1030 if board=="Morgan"			& statefips==1
replace county = 1330 if board=="Winston"			& statefips==1

* Arizona
replace county =   30 if board=="Cohise"			& statefips==4
replace county =  110 if board=="Greenlee"			& statefips==4
	
* Arkansas
replace county =  590 if board=="Hot Springs"		& statefips==5
replace county = 1190 if board=="Little Rock"		& statefips==5
replace county = 1230 if board=="St Frances"		& statefips==5

* California
replace county =   10 if board=="Berkeley"			& statefips==6
replace county =  190 if board=="Fresno (city)"		& statefips==6
replace county =  190 if board=="Fresno (county)"	& statefips==6
replace county =   10 if board=="Oakland"			& statefips==6
replace county =  370 if board=="Pasadena"			& statefips==6
replace county =  850 if board=="San Jose"			& statefips==6
replace county =  990 if board=="Stanislau"			& statefips==6
replace county =  770 if board=="Stockton"			& statefips==6

* Colorado
replace county =   30 if board=="Alamosa"			& statefips==8
replace county =  410 if board=="Colorado Springs"	& statefips==8
replace county =  250 if board=="Crowley"			& statefips==8
replace county =  810 if board=="Moffat"			& statefips==8

* Connceticut
replace county =   10 if board=="Bridgeport"		& statefips==9
replace county =   30 if board=="New Britain"		& statefips==9
replace county =   10 if board=="Stamford"			& statefips==9
replace county =   90 if board=="Waterbury"			& statefips==9

* Delaware
replace county =   30 if board=="Wilmington"		& statefips==10

* Florida
replace county =   50 if board=="Bay"				& statefips==12
replace county =   70 if board=="Bradford"			& statefips==12
replace county =   90 if board=="Brevard"			& statefips==12
replace county =  110 if board=="Broward"			& statefips==12
replace county =  350 if board=="Flagler"			& statefips==12
replace county =  530 if board=="Hernando"			& statefips==12
replace county =  310 if board=="Jacksonville"		& statefips==12
replace county =  910 if board=="Okaloosa"			& statefips==12
replace county =  930 if board=="Okeechobee"		& statefips==12
replace county =  950 if board=="Orange"			& statefips==12
replace county = 1010 if board=="Pascoe"			& statefips==12
replace county = 1030 if board=="Pinellas"			& statefips==12
replace county = 1170 if board=="Seminole"			& statefips==12
replace county =  570 if board=="Tampa"				& statefips==12

* Georgia
replace county = 1210 if board=="Atlanta"			& statefips==13
replace county = 2450 if board=="Augusta"			& statefips==13
replace county =   50 if board=="Bacon"				& statefips==13
replace county =  130 if board=="Barrow"			& statefips==13
replace county =  150 if board=="Bartow"			& statefips==13
replace county =  230 if board=="Bleckley"			& statefips==13
replace county =  430 if board=="Candler"			& statefips==13
replace county =  530 if board=="Chattaoochee"		& statefips==13
replace county =  890 if board=="Dekalb"			& statefips==13
replace county = 1070 if board=="Emmanuel"			& statefips==13
replace county = 1090 if board=="Evans"				& statefips==13
replace county = 1250 if board=="Glasscock"			& statefips==13
replace county = 2210 if board=="Oglethrope"		& statefips==13
replace county =  510 if board=="Savannah"			& statefips==13
replace county = 3090 if board=="Wheeler"			& statefips==13

* Idaho
replace county =   30 if board=="Adams"				& statefips==16
replace county =   90 if board=="Benewah"			& statefips==16
replace county =  190 if board=="Bonneville"		& statefips==16
replace county =  210 if board=="Boundary"			& statefips==16
replace county =  230 if board=="Butte"				& statefips==16
replace county =  250 if board=="Camas"				& statefips==16
replace county =  350 if board=="Clearwater"		& statefips==16
replace county =  410 if board=="Franklin"			& statefips==16
replace county =  450 if board=="Gem"				& statefips==16
replace county =  470 if board=="Gooding"			& statefips==16
replace county =  510 if board=="Jefferson"			& statefips==16
replace county =  610 if board=="Lewis"				& statefips==16
replace county =  650 if board=="Madison"			& statefips==16
replace county =  670 if board=="Minidoka"			& statefips==16
replace county =  750 if board=="Payette"			& statefips==16
replace county =  770 if board=="Power"				& statefips==16
replace county =  810 if board=="Teton"				& statefips==16
replace county =  850 if board=="Valley"			& statefips==16

* Illinois
replace county =  430 if board=="Aurora"			& statefips==17
replace county =  310 if board=="Chicago"			& statefips==17
replace county = 1830 if board=="Danville"			& statefips==17
replace county = 1150 if board=="Decatur"			& statefips==17
replace county =  390 if board=="Dewitt"			& statefips==17
replace county =  430 if board=="Dupage"			& statefips==17
replace county = 1190 if board=="East St Louis"		& statefips==17
replace county =  930 if board=="Joliet"			& statefips==17
replace county =   10 if board=="Quincy"			& statefips==17
replace county = 2010 if board=="Rockford"			& statefips==17
replace county = 1670 if board=="Springfield"		& statefips==17
replace county = 1630 if board=="St Clar"			& statefips==17

* Indiana
replace county =  330 if board=="Dekalb"			& statefips==18
replace county = 1630 if board=="EVANSVILLE"		& statefips==18
replace county =  890 if board=="East chicago"		& statefips==18
replace county =   30 if board=="Fort Wayne"		& statefips==18
replace county =  890 if board=="Gary"				& statefips==18
replace county =  970 if board=="Indianapolis"		& statefips==18
replace county = 1410 if board=="South Bend"		& statefips==18
replace county = 1670 if board=="Terre Haute"		& statefips==18
replace county = 1650 if board=="Vermilion"			& statefips==18

* Iowa
replace county =  130 if board=="Blackhawk"			& statefips==19
replace county = 1130 if board=="Cedar rapids"		& statefips==19
replace county = 1550 if board=="Council Bluffs"	& statefips==19
replace county = 1630 if board=="Davenport"			& statefips==19
replace county = 1190 if board=="Lyon"				& statefips==19
replace county = 1410 if board=="O’Brien"			& statefips==19
replace county = 1930 if board=="Sioux City"		& statefips==19
replace county =  130 if board=="Waterloo"			& statefips==19

* Kansas
replace county =  170 if board=="Chaste"			& statefips==20
replace county =  210 if board=="Cherokee"			& statefips==20
replace county =  410 if board=="Dickenson"			& statefips==20
replace county = 2090 if board=="Kansas City"		& statefips==20
replace county = 1210 if board=="Miami"				& statefips==20
replace county = 1330 if board=="Neosho"			& statefips==20
replace county = 1690 if board=="Salina"			& statefips==20
replace county = 1770 if board=="Topeka"			& statefips==20

* Kentucky
replace county = 1170 if board=="COVINGTON"			& statefips==21
replace county =  670 if board=="Lexington"			& statefips==21
replace county = 1110 if board=="Louisville"		& statefips==21
replace county = 1470 if board=="McCreary"			& statefips==21
replace county =  370 if board=="Newport"			& statefips==21

* Louisiana
replace county =   30 if board=="Allen"					& statefips==22
replace county =  110 if board=="Beauregard"			& statefips==22
replace county =  390 if board=="Evangeline"			& statefips==22
replace county =  530 if board=="Jefferson Davis"		& statefips==22
replace county =  710 if board=="New Orleans"			& statefips==22
replace county =  170 if board=="Shreveport"			& statefips==22
replace county =  950 if board=="St John the Baptist"	& statefips==22
replace county = 1130 if board=="Vermilion"				& statefips==22

* Maine
replace county =   50 if board=="Portland"			& statefips==23

* Massachusetts
replace county =   30 if board=="Adams"				& statefips==25
replace county =  150 if board=="Amherst"			& statefips==25
replace county =  170 if board=="Arlington"			& statefips==25
replace county =  270 if board=="Athol"				& statefips==25
replace county =   50 if board=="Attleboro"			& statefips==25
replace county =  170 if board=="Ayer"				& statefips==25
replace county =  170 if board=="Belmont"			& statefips==25
replace county =   90 if board=="Beverly"			& statefips==25
replace county =  250 if board=="Boston 1"			& statefips==25
replace county =  250 if board=="Boston 10"			& statefips==25
replace county =  250 if board=="Boston 11"			& statefips==25
replace county =  250 if board=="Boston 12"			& statefips==25
replace county =  250 if board=="Boston 13"			& statefips==25
replace county =  250 if board=="Boston 14"			& statefips==25
replace county =  250 if board=="Boston 15"			& statefips==25
replace county =  250 if board=="Boston 16"			& statefips==25
replace county =  250 if board=="Boston 17"			& statefips==25
replace county =  250 if board=="Boston 18"			& statefips==25
replace county =  250 if board=="Boston 19"			& statefips==25
replace county =  250 if board=="Boston 2"			& statefips==25
replace county =  250 if board=="Boston 20"			& statefips==25
replace county =  250 if board=="Boston 21"			& statefips==25
replace county =  250 if board=="Boston 22"			& statefips==25
replace county =  250 if board=="Boston 23"			& statefips==25
replace county =  250 if board=="Boston 24"			& statefips==25
replace county =  250 if board=="Boston 25"			& statefips==25
replace county =  250 if board=="Boston 3"			& statefips==25
replace county =  250 if board=="Boston 4"			& statefips==25
replace county =  250 if board=="Boston 5"			& statefips==25
replace county =  250 if board=="Boston 6"			& statefips==25
replace county =  250 if board=="Boston 7"			& statefips==25
replace county =  250 if board=="Boston 8"			& statefips==25
replace county =  250 if board=="Boston 9"			& statefips==25
replace county =  230 if board=="Brockton"			& statefips==25
replace county =  210 if board=="Brookline"			& statefips==25
replace county =  170 if board=="Cambridge"			& statefips==25
replace county =  210 if board=="Canton"			& statefips==25
replace county =  250 if board=="Chelsea"			& statefips==25
replace county =  130 if board=="Chicopee"			& statefips==25
replace county =  230 if board=="East Bridgewater"	& statefips==25
replace county =  270 if board=="East Brookfield"	& statefips==25
replace county =  170 if board=="Everett"			& statefips==25
replace county =   50 if board=="Fairhaven"			& statefips==25
replace county =   50 if board=="Fall River"		& statefips==25
replace county =  270 if board=="Fitchburg"			& statefips==25
replace county =  170 if board=="Framingham"		& statefips==25
replace county =  270 if board=="Gardner"			& statefips==25
replace county =   90 if board=="Georgetown"		& statefips==25
replace county =   90 if board=="Gloucester"		& statefips==25
replace county =  110 if board=="Greenfield"		& statefips==25
replace county =   90 if board=="Haverhill"			& statefips==25
replace county =  130 if board=="Holyoke"			& statefips==25
replace county =   90 if board=="Lawrence"			& statefips==25
replace county =   30 if board=="Lee"				& statefips==25
replace county =  270 if board=="Leominster"		& statefips==25
replace county =  170 if board=="Lowell"			& statefips==25
replace county =  130 if board=="Ludlow"			& statefips==25
replace county =   90 if board=="Lynn"				& statefips==25
replace county =  170 if board=="Malden"			& statefips==25
replace county =  170 if board=="Marlborough"		& statefips==25
replace county =  170 if board=="Medford"			& statefips==25
replace county =  170 if board=="Melrose"			& statefips==25
replace county =  270 if board=="Milford"			& statefips==25
replace county =  210 if board=="Needham"			& statefips==25
replace county =   50 if board=="New Bedford"		& statefips==25
replace county =   90 if board=="Newburyport"		& statefips==25
replace county =   30 if board=="North Adams"		& statefips==25
replace county =   50 if board=="North Easton"		& statefips==25
replace county =  150 if board=="Northampton"		& statefips==25
replace county =  210 if board=="Norwood"			& statefips==25
replace county =   90 if board=="Peabody"			& statefips==25
replace county =   30 if board=="Pittsfield"		& statefips==25
replace county =  210 if board=="Quincy"			& statefips==25
replace county =  230 if board=="Rockland"			& statefips==25
replace county =   90 if board=="Salem"				& statefips==25
replace county =  170 if board=="Somerville"		& statefips==25
replace county =  210 if board=="South Braintree"	& statefips==25
replace county =  270 if board=="Southbridge"		& statefips==25
replace county =  130 if board=="Springfield"		& statefips==25
replace county =  170 if board=="Stoneham"			& statefips==25
replace county =   90 if board=="Swampscott"		& statefips==25
replace county =   50 if board=="Taunton"			& statefips==25
replace county =  170 if board=="Tewksbury"			& statefips==25
replace county =  270 if board=="Uxbridge"			& statefips==25
replace county =  170 if board=="Waltham"			& statefips==25
replace county =  150 if board=="Ware"				& statefips==25
replace county =  170 if board=="West Newton"		& statefips==25
replace county =  130 if board=="Westfield"			& statefips==25
replace county =  250 if board=="WlNTHROP"			& statefips==25
replace county =  170 if board=="Woburn"			& statefips==25

* Michigan
replace county =  250 if board=="Battle Creek"		& statefips==26
replace county =  170 if board=="Bay City"			& statefips==26
replace county = 1630 if board=="Detroit"			& statefips==26
replace county =  490 if board=="Flint"				& statefips==26
replace county =  810 if board=="Grand Rapids"		& statefips==26
replace county = 1630 if board=="Highland Park"		& statefips==26
replace county =  650 if board=="Lansing"			& statefips==26
replace county =  470 if board=="Mackinaw"			& statefips==26
replace county = 1330 if board=="Oscesola"			& statefips==26
replace county = 1550 if board=="Shiawasee"			& statefips==26

* Minnesota
replace county = 1370 if board=="Duluth"			& statefips==27
replace county =  610 if board=="Itaska"			& statefips==27
replace county =  690 if board=="Kittson"			& statefips==27
replace county =  530 if board=="Minneapolis"		& statefips==27
replace county = 1230 if board=="St Paul"			& statefips==27
replace county = 1670 if board=="Wilkin"			& statefips==27

* Mississippi
replace county =  650 if board=="Davis"				& statefips==28
replace county = 1030 if board=="Noxubes"			& statefips==28
replace county = 1310 if board=="Stone"				& statefips==28
replace county = 1470 if board=="Walthall"			& statefips==28

* Missouri
replace county =  370 if board=="Cass"				& statefips==29
replace county =   50 if board=="Dale"				& statefips==29
replace county =  630 if board=="Dekalb"			& statefips==29
replace county =  830 if board=="Henry"				& statefips==29
replace county =  970 if board=="Joplin"			& statefips==29
replace county =  950 if board=="Kansas City"		& statefips==29
replace county =  770 if board=="Springfield"		& statefips==29
replace county =  210 if board=="St Joseph"			& statefips==29

* Montana
replace county =   30 if board=="Big Horn"			& statefips==30
replace county =   50 if board=="Blaine"			& statefips==30
replace county =  930 if board=="Butte"				& statefips==30
replace county =  110 if board=="Carter"			& statefips==30
replace county =  250 if board=="Fallon"			& statefips==30
replace county =  410 if board=="Hill"				& statefips==30
replace county =  610 if board=="Mineral"			& statefips==30
replace county =  650 if board=="Musselshell"		& statefips==30
replace county =  710 if board=="Phillips"			& statefips==30
replace county =  790 if board=="Prairie"			& statefips==30
replace county =  830 if board=="Richland"			& statefips==30
replace county =  910 if board=="Sheridan"			& statefips==30
replace county =  950 if board=="Stillwater"		& statefips==30
replace county =  1010 if board=="Toole"			& statefips==30
replace county =  1070 if board=="Wheatland"		& statefips==30
replace county =  1090 if board=="Wibaux"			& statefips==30

* Nebraska
replace county =   50 if board=="Arthur"			& statefips==31
replace county =  970 if board=="Johnson"			& statefips==31
replace county = 1030 if board=="Keyapaha"			& statefips==31
replace county = 1070 if board=="Knox"				& statefips==31
replace county =  550 if board=="Omaha"				& statefips==31

* Nevada
replace county =  210 if board=="Mineral"			& statefips==32

* New Hampshire
replace county =  110 if board=="Manchester"		& statefips==33

* New Jersey
replace county =   10 if board=="Atlantic City"		& statefips==34
replace county =  170 if board=="Bayonne"			& statefips==34
replace county =  130 if board=="East Orange"		& statefips==34
replace county =  390 if board=="Elizabeth"			& statefips==34
replace county =  170 if board=="Hoboken"			& statefips==34
replace county =  170 if board=="Jersey City"		& statefips==34
replace county =  130 if board=="Newark"			& statefips==34
replace county =  130 if board=="NewarkNo 14"		& statefips==34
replace county =  130 if board=="Orange"			& statefips==34
replace county =  310 if board=="Paterson"			& statefips==34
replace county =  230 if board=="Perth Amboy"		& statefips==34
replace county =  210 if board=="Trenton"			& statefips==34
replace county =  170 if board=="West Hoboken"		& statefips==34

* New Mexico
replace county =  110 if board=="De Baca"			& statefips==35
replace county =  250 if board=="Lea"				& statefips==35

* New York
replace county =  570 if board=="Amsterdam"			& statefips==36
replace county =  110 if board=="Auburn"			& statefips==36
replace county =   70 if board=="Binghamton"		& statefips==36
replace county =  290 if board=="Buffalo"			& statefips==36
replace county =  150 if board=="Elmira"			& statefips==36
replace county =  130 if board=="Jamestown"			& statefips==36
replace county = 1190 if board=="Mount Vernon"		& statefips==36
replace county = 1190 if board=="New Rochelle"		& statefips==36
replace county =  630 if board=="Niagara Falls"		& statefips==36
replace county =  670 if board=="Onondaga Nn 2"		& statefips==36
replace county =  270 if board=="Poughkeepsie"		& statefips==36
replace county =  550 if board=="Rochester"			& statefips==36
replace county =  670 if board=="Syracuse"			& statefips==36
replace county =  830 if board=="Troy"				& statefips==36
replace county =  650 if board=="Utica"				& statefips==36
replace county =  450 if board=="Watertown"			& statefips==36
replace county = 1190 if board=="Yonkers"			& statefips==36

* North Carolina
replace county =  110 if board=="Avery"				& statefips==37
replace county = 1190 if board=="Charlotte"			& statefips==37
replace county =  930 if board=="Hoke"				& statefips==37
replace county = 1670 if board=="Stanley"			& statefips==37
replace county = 1290 if board=="Wilmington"		& statefips==37
replace county =  670 if board=="Winston-Salem"		& statefips==37

* North Dakota
replace county =  330 if board=="Golden Valley"		& statefips==38
replace county =  450 if board=="Lamoure"			& statefips==38
replace county =  370 if board=="Plant"				& statefips==38
replace county =  850 if board=="Sioux"				& statefips==38
replace county =  870 if board=="Slope"				& statefips==38

replace board  =  "Grant" if board=="Plant" 		& statefips==38

* Ohio
replace county = 1530 if board=="Akron"				& statefips==39
replace county = 1510 if board=="Canton"			& statefips==39
replace county =  610 if board=="Cincinnati"		& statefips==39
replace county =  350 if board=="Cleveland"			& statefips==39
replace county =  490 if board=="Columbus"			& statefips==39
replace county = 1130 if board=="Dayton"			& statefips==39
replace county =  550 if board=="Geagua"			& statefips==39
replace county =   30 if board=="Lima"				& statefips==39
replace county =  890 if board=="Newark"			& statefips==39
replace county = 1250 if board=="Pauldin"			& statefips==39
replace county = 1430 if board=="Sabdusky"			& statefips==39
replace county =  230 if board=="Springfield"		& statefips==39
replace county = 1530 if board=="Summitt"			& statefips==39
replace county =  950 if board=="Toledo"			& statefips==39
replace county = 1630 if board=="Winton"			& statefips==39
replace county =  990 if board=="Youngstown"		& statefips==39
replace county = 1190 if board=="Zanesville"		& statefips==39

* Oklahoma
replace county =  330 if board=="Cotton"			& statefips==40
replace county = 1090 if board=="Oklahoma City"		& statefips==40

* Oregon
replace county =  170 if board=="Deschutes"			& statefips==41
replace county =  310 if board=="Jefferson"			& statefips==41
replace county =  510 if board=="Portland"			& statefips==41

* Pennsylvania
replace county =  770 if board=="Allentown"			& statefips==42
replace county =  130 if board=="Altoona"			& statefips==42
replace county =   70 if board=="Center"			& statefips==42
replace county =  950 if board=="Easton"			& statefips==42
replace county =  430 if board=="Harrisburg"		& statefips==42
replace county =  410 if board=="Kingstown"			& statefips==42
replace county =   30 if board=="McKeesport"		& statefips==42
replace county =  730 if board=="New Castler"		& statefips==42
replace county =  910 if board=="Norristown"		& statefips==42
replace county =   30 if board=="Pittsburgh"		& statefips==42
replace county =  110 if board=="Reading"			& statefips==42
replace county =  690 if board=="Scranton"			& statefips==42
replace county =  790 if board=="Wilkes-Barre"		& statefips==42
replace county =  810 if board=="Williamsport"		& statefips==42

* Rhode Island
replace county =   10 if board=="Barrington"		& statefips==44
replace county =   70 if board=="Burrillville"		& statefips==44
replace county =   70 if board=="Central Falls"		& statefips==44
replace county =   70 if board=="Cranston"			& statefips==44
replace county =   70 if board=="Lonsdale"			& statefips==44
replace county =   30 if board=="Opponaug"			& statefips==44
replace county =   70 if board=="Pawtucket"			& statefips==44
replace county =   90 if board=="Saunderstown"		& statefips==44
replace county =   70 if board=="WOONSOCKET"		& statefips==44

* South Carolina
replace county =  290 if board=="Celleton"			& statefips==45
replace county =  790 if board=="Columbia"			& statefips==45
replace county =  350 if board=="Dorcherster"		& statefips==45
replace county =  530 if board=="Jasper"			& statefips==45
replace county =  670 if board=="Marian"			& statefips==45
replace county =  650 if board=="McCormick"			& statefips==45

* South Dakota
replace county =  290 if board=="Coddington"		& statefips==46
replace county =  550 if board=="Haakon"			& statefips==46
replace county =  710 if board=="Jackson"			& statefips==46
replace county =  750 if board=="Jones"				& statefips==46
replace county = 1370 if board=="Ziebach"			& statefips==46

* Tennessee
replace county =  650 if board=="Chattanooga"		& statefips==47
replace county =  410 if board=="Dekalb"			& statefips==47
replace county =  930 if board=="Knoxville"			& statefips==47
replace county = 1570 if board=="Memphis"			& statefips==47
replace county =  370 if board=="Nashville"			& statefips==47

* Texas
replace county = 1810 if board=="Bill"				& statefips==48
replace county =  470 if board=="Brooks"			& statefips==48
replace county =  590 if board=="Callam"			& statefips==48
replace county =  670 if board=="Cass"				& statefips==48
replace county = 1090 if board=="Culberson"			& statefips==48
replace county = 1170 if board=="Dead Smith"		& statefips==48
replace county = 4390 if board=="Fort Worth"		& statefips==48
replace county = 2290 if board=="Hudspeth"			& statefips==48
replace county = 2470 if board=="Jim Hogg"			& statefips==48
replace county = 2490 if board=="Jim Wells"			& statefips==48
replace county = 2730 if board=="Kleberg"			& statefips==48
replace county = 2810 if board=="Lampasa"			& statefips==48
replace county = 3790 if board=="Raines"			& statefips==48
replace county = 3850 if board=="Real"				& statefips==48
replace county =  290 if board=="San Antonio"		& statefips==48
replace county = 4170 if board=="Schackleford"		& statefips==48
replace county = 4290 if board=="Stephens"			& statefips==48
replace county = 3090 if board=="Waco"				& statefips==48
replace county = 4890 if board=="Willacy"			& statefips==48
replace county = 5070 if board=="Zavalla"			& statefips==48

replace board = "Bell" if board=="Bill" & statefips==48

* Utah
replace county =  110 if board=="Davls"				& statefips==49
replace county =  130 if board=="Duchesne"			& statefips==49
replace county =  570 if board=="Ogden"				& statefips==49
replace county =  350 if board=="Salt Lake City"	& statefips==49
replace county =  470 if board=="Uinta"				& statefips==49

* Virginia
replace county =   10 if board=="Accomac"			& statefips==51
replace county = 5100 if board=="Alexandria"		& statefips==51
replace county = 1490 if board=="Prince Geogge"		& statefips==51

* Washington
replace county =  730 if board=="Bellingham City"	& statefips==53
replace county =  110 if board=="Clarke"			& statefips==53
replace county =  610 if board=="Everett"			& statefips==53
replace county =  270 if board=="Grays Harbor"		& statefips==53
replace county =  510 if board=="Pend Oreille"		& statefips==53
replace county =  330 if board=="Seattle"			& statefips==53
replace county =  530 if board=="Tacoma"			& statefips==53

* West Virginia
replace county =  390 if board=="Charleston"		& statefips==54
replace county =  110 if board=="Huntington"		& statefips==54
replace county =  690 if board=="Wheeling"			& statefips==54

* Wisconsin
replace county =   50 if board=="Barron"			& statefips==55
replace county =   70 if board=="Bayfield"			& statefips==55
replace county =   90 if board=="Green Bay"			& statefips==55
replace county =  250 if board=="Madison"			& statefips==55
replace county = 1390 if board=="Oshkosh"			& statefips==55
replace county =  310 if board=="Superior"			& statefips==55
replace county = 1330 if board=="Vernon"			& statefips==55

* Wyoming
replace county =   50 if board=="Campbell"			& statefips==56
replace county =  150 if board=="Goshen"			& statefips==56
replace county =  170 if board=="Hot Springs"		& statefips==56
replace county =  230 if board=="Lincoln"			& statefips==56
replace county =  270 if board=="Niobrara ;"		& statefips==56
replace county =  310 if board=="Platte"			& statefips==56
replace county =  430 if board=="Washakie"			& statefips==56

drop if county==.

drop board- tot_cancelled _merge error check_inducted

collapse (firstnm) statename name (sum)  tot_called_num tot_inducted_num tot_accepted_num tot_rejected_num tot_cancelled_num (mean) state, by(statefips county)
order state

label var state "State ICPSR code"
label var statefips "State FIPS code"
label var county "County code"
label var statename "State name"
label var name "County name"
label var tot_called_num "Total called"
label var tot_inducted_num "Total inducted"
label var tot_accepted_num "Total accepted"
label var tot_rejected_num "Total rejected"
label var tot_cancelled_num "Total rejected canellation of service"

compress
save "$path/Replication/cleaned_data/WWI inductions by county - clean.dta", replace
